/**
 * 饿汉式单例模式
 * */
class Singleton {
    private static Singleton instance = new Singleton();

    public static Singleton getInstance() {//全局访问入口
        return instance;
    }

    private Singleton() {//私有构造方法，防止外部实例化

    }
}
    public class demo1{
        public static void main(String[] args) {
            Singleton s1=Singleton.getInstance();
            Singleton s2=Singleton.getInstance();
            System.out.println(s1==s2);
        }
}
